package com.example.controller;

import com.example.annotation.PassToken;
import com.example.utils.RediLock;
import com.example.utils.RedisYmlUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.*;

/**
 * Create By ChenXiAoBin
 * on 2019/4/16
 */
@RestController
@RequestMapping("/V1.0/redis")
public class RedisController {
    @Autowired
    private RedisTemplate<Object, Object> template;

    private Logger LOG = Logger.getLogger(String.valueOf(this.getClass()));

    @GetMapping("/puth/mess/{id}")
    @PassToken
    @ApiOperation(value = "valuel路径传参数", notes = "note valuel路径传参数")
    public void puthMess(@ApiParam(name="id", value = "id路径", required = true) @PathVariable("id") Integer id){
        if (!RediLock.tryLock(id.toString(), 5)) {
            return;
        }
        RediLock.unLock(id.toString());
//        template.opsForValue().get("123");
    }

    @PutMapping("/update")
    public void putupdate(
            @ApiParam(name = "id", value = "修改参数")
            @RequestParam(name = "id", required = false) Integer id) {
        Map map = new TreeMap();
        LOG.info(id);
    }
}
